
// _c()
export function createElementVnode(vm, tag, data = {}, ...children) {
    // 取出 key
    let key = data.key;

    if (key) {
        // 去完 key 之后将 data 中的 key 删除
        delete data.key;
    }

    return vnode(vm, tag, key, data, children);
}

// _v()
export function createTextVnode(vm, text) {
    return vnode(vm, undefined, undefined, undefined, undefined, text);
}

// _e()
export function createCommentVnode(vm, comment) {
    return vnode(vm, undefined, undefined, undefined, undefined, undefined, comment);
}

// 虚拟dom 描述 dom元素，可以增加一些自定义属性
function vnode(vm, tag, key, data, children, text, comment) {
    return {
        vm,
        tag,
        key,
        data,
        children,
        text,
        comment,
    }
}